﻿IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[esf_files].[P_ListFileReferenceLastUpdateAction]') AND type in (N'P', N'PC'))
	DROP PROCEDURE [esf_files].P_ListFileReferenceLastUpdateAction
GO


CREATE PROCEDURE esf_files.P_ListFileReferenceLastUpdateAction
	@pMonitoredDirectoryID INT
	,@pSearch VARCHAR (1000) = NULL
AS

	SELECT
		DISTINCT
		LastUpdateAction
	FROM
		esf_files.FileReference FR
	WHERE
		FR.MonitoredDirectoryID = @pMonitoredDirectoryID
		AND (@pSearch IS NULL OR FR.LastUpdateAction LIKE @pSearch)